package com.web.common.iot.mqtt.entity;

public enum MqttMessageType {
	
	CONNECTED("connected", "连接完成"),
	DISCONNECTED("disconnected", "连接断开"),
	SUBSCRIBED("subscribed", "主题订阅"),
	UNSUBSCRIBED("unsubscribed", "取消订阅"),
	DELIVERED("delivered", "消息投递"),
	DROPPED("dropped", "丢弃消息");
	;

	private String type;
	
	private String message;
	
	private MqttMessageType(String type, String message){
		this.type = type;
		this.message = message;
	}

	public String getType() {
		return type;
	}

	public String getMessage() {
		return message;
	}
	
	/**
	 * 根据MQTT消息类型获取消息描述
	 * @param type MQTT消息类型
	 * @return String 消息内容
	 *
	 * @author zhouhui
	 * @since 1.0.0
	 */
	public static String getMessageByType(String type) {
		for(MqttMessageType item: MqttMessageType.values()) {
			if(item.getType().equals(type)) {
				return item.getMessage();
			}
		}
		return null;
	}
}
